package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface InspectionUnitDao {

    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

    Page<CheckGroup> findPage(QueryPageBean queryPageBean);


    @Select("select * from t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);


    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteInspectionUnit(Integer id);

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteInspectionUnitAndCheckItem(Integer id);

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);

    @Delete("delete from t_setmeal_checkgroup where checkgroup_id = #{id}")
    void deleteInspectionUnitAndSetmeal(Integer id);


    Integer addInspectionUnit(CheckGroup checkGroup);

    void addInspectionUnitAndCheckItem(@Param("id")Integer id, @Param("checkitemIds")List<Integer> checkitemIds);

    void editInspectionUnit(CheckGroup checkGroup);

}
